/*
Copyright (c) 2008
Heka Lok <heka.lok@gmail.com>
David Feilen <bastian.mezurashii@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

module defl.c.ecore.evas;

private import defl.c.ecore.x.x;
private import defl.c.evas.evas;

extern (C)
{
  const int HAVE_ECORE_EVAS_X = 1;
  const int HAVE_ECORE_EVAS_FB = 1;
  const int HAVE_ECORE_EVAS_X11_GL = 1;
  const int HAVE_ECORE_EVAS_X11_16 = 1;
  const int HAVE_ECORE_EVAS_DIRECTFB = 1;
  const int HAVE_ECORE_EVAS_WIN32 = 1;
  const int HAVE_ECORE_EVAS_SDL = 1;

  enum Ecore_Evas_Engine_Type
  {
    ECORE_EVAS_ENGINE_SOFTWARE_X11,
    ECORE_EVAS_ENGINE_SOFTWARE_FB,
    ECORE_EVAS_ENGINE_GL_X11,
    ECORE_EVAS_ENGINE_SOFTWARE_BUFFER,
    ECORE_EVAS_ENGINE_XRENDER_X11,
    ECORE_EVAS_ENGINE_DIRECTFB,
    ECORE_EVAS_ENGINE_SOFTWARE_X11_16,
    ECORE_EVAS_ENGINE_SOFTWARE_DDRAW,
    ECORE_EVAS_ENGINE_SOFTWARE_DDRAW_16,
    ECORE_EVAS_ENGINE_DIRECT3D,
    ECORE_EVAS_ENGINE_SDL
  };

  enum Ecore_Evas_Avoid_Damage_Type
  {
    ECORE_EVAS_AVOID_DAMAGE_NONE = 0,
    ECORE_EVAS_AVOID_DAMAGE_EXPOSE = 1,
    ECORE_EVAS_AVOID_DAMAGE_BUILT_IN = 2
  };

  //XXX Use version() instead ?
  alias void Ecore_DirectFB_Window;
  alias void Ecore_Win32_Window;
  alias void Ecore_Evas;

  /* module setup/shutdown calls */

  int         ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type engine);

  int         ecore_evas_init();
  int         ecore_evas_shutdown();

  /* engine/target specific init calls */
  Ecore_Evas     *ecore_evas_software_x11_new(char *disp_name, Ecore_X_Window parent, 
                                              int x, int y, int w, int h);
  Ecore_X_Window  ecore_evas_software_x11_window_get(Ecore_Evas *ee);
  Ecore_X_Window  ecore_evas_software_x11_subwindow_get(Ecore_Evas *ee);
  void            ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee, int on);
  int             ecore_evas_software_x11_direct_resize_get(Ecore_Evas *ee);
  void            ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win);

  Ecore_Evas     *ecore_evas_gl_x11_new(char *disp_name, Ecore_X_Window parent, 
                                        int x, int y, int w, int h);
  Ecore_X_Window  ecore_evas_gl_x11_window_get(Ecore_Evas *ee);
  Ecore_X_Window  ecore_evas_gl_x11_subwindow_get(Ecore_Evas *ee);
  void            ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee, int on);
  int             ecore_evas_gl_x11_direct_resize_get(Ecore_Evas *ee);
  void            ecore_evas_gl_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win);

  Ecore_Evas     *ecore_evas_xrender_x11_new(char *disp_name, Ecore_X_Window parent, 
                                             int x, int y, int w, int h);
  Ecore_X_Window  ecore_evas_xrender_x11_window_get(Ecore_Evas *ee);
  Ecore_X_Window  ecore_evas_xrender_x11_subwindow_get(Ecore_Evas *ee);
  void            ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee, int on);
  int             ecore_evas_xrender_x11_direct_resize_get(Ecore_Evas *ee);
  void            ecore_evas_xrender_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win);

  Ecore_Evas     *ecore_evas_software_x11_16_new(char *disp_name, Ecore_X_Window parent, 
                                                 int x, int y, int w, int h);
  Ecore_X_Window  ecore_evas_software_x11_16_window_get(Ecore_Evas *ee);
  Ecore_X_Window  ecore_evas_software_x11_16_subwindow_get(Ecore_Evas *ee);
  void            ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee, int on);
  int             ecore_evas_software_x11_16_direct_resize_get(Ecore_Evas *ee);
  void            ecore_evas_software_x11_16_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win);

  Ecore_Evas     *ecore_evas_fb_new(char *disp_name, int rotation, int w, int h);

  Ecore_Evas            *ecore_evas_directfb_new(char *disp_name, int windowed, 
                                                 int x, int y, int w, int h);
  Ecore_DirectFB_Window *ecore_evas_directfb_window_get(Ecore_Evas *ee);

  Ecore_Evas     *ecore_evas_buffer_new(int w, int h);
  int            *ecore_evas_buffer_pixels_get(Ecore_Evas *ee);
  Evas_Object    *ecore_evas_object_image_new(Ecore_Evas *ee_target);

  Ecore_Evas         *ecore_evas_software_ddraw_new(Ecore_Win32_Window *parent,
                                                    int x, int y, int width, int height);
  Ecore_Win32_Window *ecore_evas_software_ddraw_window_get(Ecore_Evas *ee);

  Ecore_Evas         *ecore_evas_software_ddraw_16_new(Ecore_Win32_Window *parent,
                                                       int x, int y, int width, int height);
  Ecore_Win32_Window *ecore_evas_software_ddraw_16_window_get(Ecore_Evas *ee);

  Ecore_Evas         *ecore_evas_direct3d_new(Ecore_Win32_Window *parent,
                                              int x, int y, int width, int height);
  Ecore_Win32_Window *ecore_evas_direct3d_window_get(Ecore_Evas *ee);

  Ecore_Evas     *ecore_evas_sdl_new(char* name, int w, int h, 
                                     int fullscreen, int hwsurface, int noframe, int alpha);

  /* generic manipulation calls */
  Ecore_Evas *ecore_evas_ecore_evas_get(Evas *e);
  void        ecore_evas_free(Ecore_Evas *ee);
  void       *ecore_evas_data_get(Ecore_Evas *ee, char *key);
  void        ecore_evas_data_set(Ecore_Evas *ee, char *key, void *data);
  void        ecore_evas_callback_resize_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_move_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_show_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_hide_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_delete_request_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_destroy_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_focus_in_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_focus_out_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_sticky_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_unsticky_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_mouse_out_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_pre_render_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  void        ecore_evas_callback_post_render_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee));
  Evas*       ecore_evas_get(Ecore_Evas *ee);
  void        ecore_evas_move(Ecore_Evas *ee, int x, int y);
  void        ecore_evas_managed_move(Ecore_Evas *ee, int x, int y);
  void        ecore_evas_resize(Ecore_Evas *ee, int w, int h);
  void        ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, int w, int h);
  void        ecore_evas_geometry_get(Ecore_Evas *ee, int *x, int *y, int *w, int *h);
  void        ecore_evas_rotation_set(Ecore_Evas *ee, int rot);
  int         ecore_evas_rotation_get(Ecore_Evas *ee);
  void        ecore_evas_shaped_set(Ecore_Evas *ee, int shaped);
  int         ecore_evas_shaped_get(Ecore_Evas *ee);
  void        ecore_evas_alpha_set(Ecore_Evas *ee, int alpha);
  int         ecore_evas_alpha_get(Ecore_Evas *ee);
  void        ecore_evas_show(Ecore_Evas *ee);
  void        ecore_evas_hide(Ecore_Evas *ee);
  int         ecore_evas_visibility_get(Ecore_Evas *ee);
  void        ecore_evas_raise(Ecore_Evas *ee);
  void        ecore_evas_lower(Ecore_Evas *ee);
  void        ecore_evas_title_set(Ecore_Evas *ee, char *t);
  char*       ecore_evas_title_get(Ecore_Evas *ee);
  void        ecore_evas_name_class_set(Ecore_Evas *ee, char *n, char *c);
  void        ecore_evas_name_class_get(Ecore_Evas *ee, char **n, char **c);
  void        ecore_evas_size_min_set(Ecore_Evas *ee, int w, int h);
  void        ecore_evas_size_min_get(Ecore_Evas *ee, int *w, int *h);
  void        ecore_evas_size_max_set(Ecore_Evas *ee, int w, int h);
  void        ecore_evas_size_max_get(Ecore_Evas *ee, int *w, int *h);
  void        ecore_evas_size_base_set(Ecore_Evas *ee, int w, int h);
  void        ecore_evas_size_base_get(Ecore_Evas *ee, int *w, int *h);
  void        ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h);
  void        ecore_evas_size_step_get(Ecore_Evas *ee, int *w, int *h);
  void        ecore_evas_cursor_set(Ecore_Evas *ee, char *file, int layer, int hot_x, int hot_y);
  void        ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y);
  void        ecore_evas_cursor_get(Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y);
  void        ecore_evas_layer_set(Ecore_Evas *ee, int layer);
  int         ecore_evas_layer_get(Ecore_Evas *ee);
  void        ecore_evas_focus_set(Ecore_Evas *ee, int on);
  int         ecore_evas_focus_get(Ecore_Evas *ee);
  void        ecore_evas_iconified_set(Ecore_Evas *ee, int on);
  int         ecore_evas_iconified_get(Ecore_Evas *ee);
  void        ecore_evas_borderless_set(Ecore_Evas *ee, int on);
  int         ecore_evas_borderless_get(Ecore_Evas *ee);
  void        ecore_evas_override_set(Ecore_Evas *ee, int on);
  int         ecore_evas_override_get(Ecore_Evas *ee);
  void        ecore_evas_maximized_set(Ecore_Evas *ee, int on);
  int         ecore_evas_maximized_get(Ecore_Evas *ee);
  void        ecore_evas_fullscreen_set(Ecore_Evas *ee, int on);
  int         ecore_evas_fullscreen_get(Ecore_Evas *ee);
  void        ecore_evas_withdrawn_set(Ecore_Evas *ee, int withdrawn);
  int         ecore_evas_withdrawn_get(Ecore_Evas *ee);
  void        ecore_evas_sticky_set(Ecore_Evas *ee, int sticky);
  int         ecore_evas_sticky_get(Ecore_Evas *ee);
  void        ecore_evas_ignore_events_set(Ecore_Evas *ee, int ignore);
  int         ecore_evas_ignore_events_get(Ecore_Evas *ee);
  void*       ecore_evas_window_get(Ecore_Evas* ee);

  void   ecore_evas_avoid_damage_set(Ecore_Evas *ee, Ecore_Evas_Avoid_Damage_Type on);
  Ecore_Evas_Avoid_Damage_Type ecore_evas_avoid_damage_get(Ecore_Evas *ee);

}
